<?php
/**
  * 管理员模型
  */
class AdministratorModel extends CommonModel
{
	protected $_validate=array(
		array('role_id','checkRole','请选择所属角色！',self::MUST_VALIDATE,'callback',self::MODEL_BOTH),
		array('username','require','用户名必须！',self::MODEL_BOTH),
		array('username','','用户名已经存在',0,'unique',1)
		);

	protected $_auto=array(
		array('add_time','time',self::MODEL_BOTH,'function'),
		array('password','md5',self::MODEL_INSERT,'function'),
		array('status','callbackStatus',self::MODEL_UPDATE,'callback'),
		array('is_super','callbackIsSuper',self::MODEL_BOTH,'callback')
		);

	protected function callbackIsSuper()
	{
	  if(isset($_POST['is_super']))
	  {
	  	return 1;
	  }else{return 0;}
	}	

	protected function checkRole()
	{
		if($_POST['role_id']==0)
		{
			return false;
		}else
		    {
		      return true;
		    }
	}

}
?>